Skip to content

fix: Respect minWidth for dynamically added columns in resizable mode#4241

Open
kaigritun wants to merge 1 commit intocloudscape-design:mainfrom
kaigritun:fix/resizable-columns-minwidth
Open

fix: Respect minWidth for dynamically added columns in resizable mode#4241
kaigritun wants to merge 1 commit intocloudscape-design:mainfrom
kaigritun:fix/resizable-columns-minwidth

Conversation

@kaigritun
Copy link

Description

Fixes #4236

When columns are dynamically added to a table with resizableColumns enabled, the minWidth property was being ignored. Instead, columns defaulted to DEFAULT_COLUMN_WIDTH (120px) even when they had a minWidth property set.

Problem

In use-column-widths.tsx, the code path for dynamically added columns (line ~171) only checked column.width:

newColumnWidths.set(column.id, (column.width as number) || DEFAULT_COLUMN_WIDTH);

This is inconsistent with the initial render behavior in readWidths() (lines 27-32), which correctly handles minWidth:

let width = (column.width as number) || 0;
const minWidth = (column.minWidth as number) || width || DEFAULT_COLUMN_WIDTH;
result.set(column.id, Math.max(width, minWidth));

Solution

Apply the same logic to dynamically added columns, ensuring minWidth is respected consistently:

const width = (column.width as number) || 0;
const minWidth = (column.minWidth as number) || width || DEFAULT_COLUMN_WIDTH;
newColumnWidths.set(column.id, Math.max(width, minWidth));

Testing

Added a new test case should respect minWidth for dynamically added columns without explicit width that:

  1. Renders a table with only one visible column
  2. Dynamically adds columns that have minWidth but no explicit width
  3. Verifies the columns respect their minWidth values instead of falling back to DEFAULT_COLUMN_WIDTH

All existing tests continue to pass.

…le mode

When columns are dynamically added to a table with resizableColumns enabled,
the minWidth property is now correctly applied, consistent with the initial
render behavior in readWidths().

Previously, dynamically added columns without explicit width would default
to DEFAULT_COLUMN_WIDTH (120px) even if they had a minWidth property set.

Fixes cloudscape-design#4236
@kaigritun kaigritun requested a review from a team as a code owner February 11, 2026 15:43
@kaigritun kaigritun requested review from SpyZzey and removed request for a team February 11, 2026 15:43
@kaigritun kaigritun changed the title fix(table): respect minWidth for dynamically added columns in resizable mode fix: Respect minWidth for dynamically added columns in resizable mode Feb 11, 2026
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (40696d3) to head (3c10ef0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4241   +/-   ##
=======================================
  Coverage   97.19%   97.19%           
=======================================
  Files         886      886           
  Lines       26017    26019    +2     
  Branches     9431     9431           
=======================================
+ Hits        25287    25289    +2     
- Misses        683      724   +41     
+ Partials       47        6   -41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: resizableColumns: dynamically added columns ignore minWidth, fall back to DEFAULT_COLUMN_WIDTH

1 participant